package com.lxj.controller.bus;

import com.lxj.common.Result;
import com.lxj.domain.BusCustomer;
import com.lxj.dto.BusCustomDto;
import com.lxj.service.CustomService;
import com.lxj.vo.PageInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lxj
 * @date 2021/6/21 9:44
 * @Description:
 */
@RestController
@RequestMapping("/buscustom")
public class BusCustomController {

    @Autowired
    private CustomService customService;

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/findByPage.do")
    @RequiresPermissions(value = "custom:list")
    public Result findByPage(BusCustomDto dto){
        PageInfo<BusCustomer> pageInfo = customService.findByPage(dto);
        return new Result(pageInfo);
    }

    /**
     * 新增
     * @param dto
     * @return
     */
    @PostMapping("/add.do")
    @RequiresPermissions(value = "custom:add")
    public Result add(@RequestBody BusCustomDto dto){
        return customService.add(dto);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @PostMapping("/delete.do/{ids}")
    @RequiresPermissions(value = "custom:delete")
    public Result batchDelete(@PathVariable("ids") Integer[] ids){
        return customService.batchDelete(ids);
    }

    /**
     * 修改
     * @param dto
     * @return
     */
    @PostMapping("/update.do")
    @RequiresPermissions(value = "custom:update")
    public Result update(@RequestBody BusCustomDto dto){
        return customService.updateById(dto);
    }
}
